package com.wc.blue_bridge_history.Java14Q.B_与或异或;

/**
 * @Author congge
 * @Date 2024/3/24 15:50
 * @description
 */
public class Main {
    static char[] opA = new char[]{' ', '|', '&', '^'};
    static int[] opB = new int[]{0, 1};
    static int[][] num = new int[10][10];
    static char[] ops = new char[11];
    static int res = 0;
    static int sum = 0;

    public static void main(String[] args) {
        num[0] = new int[]{1, 0, 1, 0, 1};
        dfs(0);
        System.out.println(res);
    }

    static void dfs(int u1) {
        if (u1 == 10) {
            res += cal();
            sum ++;
            return;
        }
        for (int i = 1; i <= 3; i++) {
            ops[u1] = opA[i];
            dfs(u1 + 1);
        }
    }

    static int cal() {
        int idx = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4 - i; j++) {
                num[i + 1][j] = cal(num[i][j], num[i][j + 1], ops[idx++]);
            }
        }

        return num[4][0];
    }

    static int cal(int l, int r, char op) {
        if (op == '|') return l | r;
        if (op == '&') return l & r;
        return l ^ r;
    }
}
